package com.ebookstore.struts.action;

import org.apache.struts.action.ActionServlet;
import org.apache.struts.actions.DispatchAction;

import com.ebookstore.service.EBookStoreFacade;
import com.ebookstore.service.EBookStoreFactory;

public class BaseAction extends DispatchAction {
	private EBookStoreFacade eBookStore;

	/*
	 * 覆盖父类中的方法，初始化EBookStoreFacade对象
	 * 
	 * @see org.apache.struts.action.Action#setServlet(org.apache.struts.action.ActionServlet)
	 */
	public void setServlet(ActionServlet actionServlet) {
		super.setServlet(actionServlet);
		// 通过singleton模式创建
		eBookStore = EBookStoreFactory.getInstance();
	}

	/**
	 * 获得EBookStoreFacade对象
	 * 
	 * @return
	 */
	protected EBookStoreFacade getEBookStore() {
		return eBookStore;
	}
}
